<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>后台主界面</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href='<?php echo $static_url; ?>common/css/admin.css' type="text/css" />
<link rel="stylesheet" href='<?php echo $static_url; ?>common/css/daily_record.css' type="text/css" />
<link rel="stylesheet" href='<?php echo $static_url; ?>common/css/news_list.css' type="text/css" />
<script src="<?php echo $static_url; ?>common/js/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="<?php echo $static_url; ?>common/js/common.js" type="text/javascript"></script>
</head>
<body class="body_background">
	<div>
		<?php echo $header_nav; ?>
		<div class="common_container clearfix">
			<div class="crumbs">
				<span class="catalogue">名人</span>
				<a href="/www/admin/star/star_lists.php">名人列表</a> |
				<a href="/www/admin/star/star_add.php">添加名人</a> |
				<a onclick="add_empty();" href="javascript:;">添加空白档</a> | 
				<a href="/www/admin/star/star_recover.php">回收站</a> |
				<a href="/www/admin/star/star_search.php">搜索名人</a>
			</div>
			<div class="daily_record_menu" id="side_container">
				<div class="closeSidebar"><i title="点击隐藏左菜单" class="icon_close"></i></div>
				<ul class="record_menu">
					<li style="font-size:14px;">名人</li>
					<li><a href="/www/admin/star/star_lists.php"> └ 名人列表</a></li>
					<li><a href="/www/admin/star/star_add.php"> └ 添加名人</a></li>
					<li><a onclick="add_empty();" href="javascript:;"> └ 添加空白档</a></li>
					<li><a href="/www/admin/star/star_recover.php"> └ 回收站</a></li>
					<li><a href="/www/admin/star/star_search.php"> └ 搜索名人</a></li>
				</ul>
			</div>
			<div class="sidebar_container_hidden" style="margin-top:10px;margin-right:5px;" >
				<div class="openSidebar"><i title="点击显示左菜单" class="icon_open"></i></div>
			</div>
			<div class="daily_record_main" id="main_container">
				<div class="news_main_container">
					<table class="record_tips"><tr><td class="colorstyle">名人列表</td></tr></table>
					<form id="star_form" action="/www/admin/star/do/do_order.php" method="post">
					<table class="news_table">
						<thead>
							<tr>
								<th><div align="center"><input id="check_box" type="checkbox" onclick="selectall('ids[]');" value=""></div></th>
								<th>排序</th>
								<th>ID</th>
								<th>标题</th>
								<th>点击量</th>
								<th>发布人</th>
								<th>更新时间</th>
								<th>管理操作</th>
							</tr>
						</thead>
						<tbody>
							<?php foreach($star_rs as $row): ?>
							<tr>
								<td><input type="checkbox" value="<?php echo $row['title_id']; ?>" name="ids[]"></td>
								<td>
									<input type="text" name="orders[]" value="<?php echo $row['orders']; ?>" style="width:40px;text-align:center;border:0;">
								</td>
								<td>
									<?php echo $row['title_id']; ?>
									<input type="hidden" name="title_id[]" value="<?php echo $row['title_id']; ?>" >
								</td>
								<td>
									<?php
									if( $row['is_empty']==2 ){
										if( $row['updated']>1372236572 ){
											echo '<a target="_blank" href="http://star.zgqw.com/v/'.$row['title_id'].'">'.$row['title'].'</a>';
										}else{
											echo '<a target="_blank" href="http://star.zgqw.com/show.php?title_id='.$row['title_id'].'">'.$row['title'].'</a>';
										}
									}else{
										echo $row['title'];
									}
									?>
								</td>
								<td><?php echo $row['click_views']; ?></td>
								<td><?php echo $row['create_username']; ?></td>
								<td><?php echo date('Y-m-d H:i:s',$row['updated']); ?></td>
								<td>
									<?php
									if( $row['is_empty']==2 ){
										if( $row['updated']>1372236572 ){
											echo '<a target="_blank" href="http://star.zgqw.com/v/'.$row['title_id'].'">预览 | </a>';
										}else{
											echo '<a target="_blank" href="http://star.zgqw.com/show.php?title_id='.$row['title_id'].'">预览 | </a>';
										}
									}else{
										echo '预览 | ';
									}
									?>
									<a href="javascript:;" onclick="set_top('<?php echo $row['title_id']; ?>');" id="index_top_<?php echo $row['title_id']; ?>">
										<?php if($row['index_top']==1){echo '置顶';}else{echo '已置顶';}; ?>
									</a> | 
									<a href="/www/admin/star/star_edit.php?title_id=<?php echo $row['title_id']; ?>&this_history_id=<?php echo $row['title_history_id']?>">修改</a> |
									<a href="javascript:del_star('<?php echo $row['title_id']; ?>');" onclick="return confirm('确定要删除《<?php echo $row['title']; ?>》这个名人吗？')" >删除</a>
								</td>
							</tr>
							<?php endforeach; ?>
						</tbody>
						<tfoot>
							<tr>
								<td colspan="8" style="text-align:left">
									&nbsp;&nbsp;&nbsp;<label for="check_box">全选/取消</label>&nbsp;&nbsp;&nbsp;
									<a class="btn" href="javascript:;" onclick="{if(confirm('确定删除所选名人？')){delAll();}return false;}">删除</a>&nbsp;&nbsp;&nbsp;
									<a href="javascript:;" onclick="document.getElementById('star_form').submit();">排序</a>
								</td>
							</tr>
							<?php if( $page_html != '' ): ?>
							<tr>
								<td class="navPage" colspan="8">&nbsp;&nbsp;<?php echo $page_html; ?></td>
							</tr>
							<?php endif; ?>
						</tfoot>
					</table>
					</form>
				</div>
			</div>
		</div>
	</div>
<script>
//添加空白档
function add_empty(){
	$.ajax({
		type: "POST",
		url: "/admin/star/ajax/ajax_add_empty.php",
		dataType:'json',
		success: function(msg){
			alert(msg.string);
			window.location.href="/www/admin/star/star_lists.php";
		}
	});
}

//删除
function del_star(i){<!-- i:id号 -->
	$.ajax({
		type: "POST",
		url: "/admin/star/ajax/ajax_del.php",
		dataType:'json',
		data: "id="+i,
		success: function(msg){
			alert(msg.string);
			if(msg.error){
				window.top.location.reload();
			}
		}
	});
}

/**
* 全选checkbox,注意：标识checkbox id固定为为check_box
* @param string name 列表check名称,如 uid[]
*/
function selectall(name) {
	if ($("#check_box").attr("checked")=='checked') {
		$("input[name='"+name+"']").each(function() {
			$(this).attr("checked","checked");
		});
	} else {
		$("input[name='"+name+"']").each(function() {
			$(this).removeAttr("checked");
		});
	}
} 

//批量删除
function delAll(){
	var checks = '';
	$("input[name='ids[]'][type=checkbox]:checked").each(function() {
		checks += $(this).val() + "|";//动态拼取选中的checkbox的值，用“|”符号分隔
	});
	$.ajax({
		type: "POST",
		url: "/admin/star/ajax/ajax_delAll.php",
		dataType:'json',
		data: "title_id="+checks,
		success: function(msg){
			alert(msg.string);
			if(msg.error){
				window.top.location.reload();
			}
		}
	});
}

//设置置顶
function set_top(i){
	$.ajax({
		type: "POST",
		url: "/admin/star/ajax/ajax_top.php",
		dataType:'json',
		data: "title_id="+i,
		success: function(msg){
			if(msg.error===true){
				$("#index_top_"+i).html(msg.string);
			}else{
				alert(msg.string);
			}
		}
	});
}
</script>
</body>
</html>